// Fast conversion from a IEEE 32-bit floating point number F in [0,1] to a
// a 32-bit integer I in [0,2^L-1].
//
//   fFloat = F
//   iLog = L
//   iInt = I

#define E_SCALED_FLOAT_TO_INT(fFloat,iLog,iInt)                  \
{                                                                \
    int iShift = 150 - iLog - ((*(int*)(&fFloat) >> 23) & 0xFF); \
    if ( iShift < 24 )                                           \
    {                                                            \
        iInt = ((*(int *)(&fFloat) & 0x007FFFFF) |               \
            0x00800000) >> iShift;                               \
        if ( iInt == (1 << iLog) )                               \
        {                                                        \
            iInt--;                                              \
        }                                                        \
    }                                                            \
    else                                                         \
    {                                                            \
        iInt = 0;                                                \
    }                                                            \
}
